Skip to content

Add sample: remove site collection admins after providing support#971

Merged
pkbullock merged 1 commit into
pnp:mainfrom
fabianhutzli:remove-sitecollection-admins-after-providing-support
Jul 15, 2026
Merged

Add sample: remove site collection admins after providing support#971
pkbullock merged 1 commit into
pnp:mainfrom
fabianhutzli:remove-sitecollection-admins-after-providing-support

Conversation

@fabianhutzli

Copy link
Copy Markdown
Contributor

Summary

Site collection administrator access granted temporarily to support staff (for tickets/access requests) is often never revoked once the case is closed. This sample provides a two-step, CSV-driven workflow to find and clean up these leftover, directly-assigned site collection admins across a tenant.

Features

  • Loops through every site collection in the tenant and checks its site collection administrators against a known list of support/admin accounts ($Administrators)
  • Only considers directly assigned site collection administrators, not group/team owners or other inherited roles
  • Exports matches to SitesSCAdmin.csv with an empty Remove column for manual review
  • On a follow-up run, imports the reviewed SitesSCAdmin_cleanup.csv, filters for rows flagged x in the Remove column, and removes those site collection administrators
  • Includes a tip recommending non-interactive authentication (certificate/client secret) instead of -Interactive for regular/unattended runs

Script type

PnP PowerShell

Author

Fabian Hutzli

Adds a PnP PowerShell script sample that reports directly-assigned
site collection administrators matching known support/admin accounts
across the tenant, and removes them once flagged for cleanup in a
follow-up CSV-driven run.

@pkbullock pkbullock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another cool sample Fabian, thank you for sharing with the community 🤓🥳🤩 This will be live shortly.

@pkbullock pkbullock merged commit f7f9e07 into pnp:main Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants